/*
 * ResidueTypes.h
 *
 *  Created on: May 21, 2012
 *      Author: marchi
 */

#ifndef RESIDUETYPES_H_
#define RESIDUETYPES_H_
#include <string>
#include <vector>
#include <iostream>
#include <cstdlib>
using std::cout;
using std::endl;
using std::string;
using std::vector;

namespace Topol_NS {
const int TOTTYPES=5;
enum {Prot, Water, Ions, Surf, Dna};
class ResidueTypes {
	static string Residue[TOTTYPES];
	static string types[TOTTYPES];
public:
	ResidueTypes(){};
	static int find(string & y){
		string x=y+" ";
		try{
			for(int n=0;n<TOTTYPES;n++)
				if(Residue[n].find(x.c_str()) != string::npos) return n;
			if(y.size()>3)
				for(int n=0;n<TOTTYPES;n++){
					string tmp=y.substr(0,y.size()-1)+" ";
					if(Residue[n].find(tmp.c_str()) != string::npos) return n;
				}
			throw string(" Can\'t find pdb residue " + y + " in the internal list ");
		}
		catch(const string & s){
			cout << s << endl;
			exit(-1);
		}
		return -1;
	}
	static string Sfind(string & y){
		return types[find(y)];
	}
	static string gettypes(int n){return types[n];};
	virtual ~ResidueTypes();
	};
};
#endif /* RESIDUETYPES_H_ */
